<% title _("Changed environments") %>
<%= form_tag send("obsolete_and_new_#{controller_name}_path") do %>
  <h4><%= _("Select the changes you want to apply to Foreman") %></h4>
  <h6>
  <%= _("Toggle") %>:
  <%= link_to_function(icon_text("check", _("New")),
                       "toggleCheckboxesBySelector('.env_select_boxes_new')",
                       :title => _("Check/Uncheck new")) %> |
  <%= link_to_function(icon_text("check", _("Updated")),
                       "toggleCheckboxesBySelector('.env_select_boxes_updated')",
                       :title => _("Check/Uncheck updated")) %> |
  <%= link_to_function(icon_text("check", _("Obsolete")),
                       "toggleCheckboxesBySelector('.env_select_boxes_obsolete')",
                       :title => _("Check/Uncheck obsolete")) %>
  </h6>
  <table class="<%= table_css_classes %>">
    <thead>
      <tr>
        <th class="ca">
          <%= link_to_function(icon_text("check"),
                               "toggleCheckboxesBySelector('.env_select_boxes')",
                               :title => _("Check/Uncheck all")) %>
        </th>
        <th><%= _("Environment") %></th>
        <th><%= _("Operation") %></th>
        <th><%= _("Puppet Modules") %></th>
      </tr>
    </thead>
    <tbody>
      <% for kind in ["new", "obsolete", "updated", "ignored"] %>
        <% unless (envs = @changed[kind]).empty? %>
          <% for env in envs.keys.sort %>
            <tr>
              <% unless kind == 'ignored' %>
                <td>
                  <%= check_box_tag "changed[#{kind}][#{env}]", @changed[kind][env].to_json, false, :class => "env_select_boxes env_select_boxes_#{kind} env_select_boxes_env_#{env}" %>
                </td>
                <td>
                  <%= link_to_function("#{env}", "toggleCheckboxesBySelector('.env_select_boxes_env_#{env}')", :title => _("Check/Uncheck all %s changes") % env) %>
                </td>
              <% else %>
                <td>&nbsp;</td>
                <td><%= env %></td>
              <% end %>
              <td>
                <%= {"new" => _("Add:"), "obsolete" => _("Remove:"), "updated" => _("Update:"), "ignored" => _("Ignored:")}[kind] %>
              </td>
              <td>
                <% pcs = @changed[kind][env] %>
                <%= class_update_text pcs, env %>
              </td>
            </tr>
          <% end %>
        <% end %>
      <% end %>
    </tbody>
  </table>
  <div>
    <%= link_to _("Cancel"), send("#{controller_name}_path"), :class => "btn btn-default" %>
    <%= submit_tag _("Update"), :class => "btn btn-primary" %>
  </div>
<% end %>
